package userdata;

/*import com.romaremez.testuser.src.datautils.Results;
import com.romaremez.testuser.src.testsystem.QuestionStep; */

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import datautils.Results;
import testsystem.QuestionStep;

public class UserSession implements Serializable  {
    private List<QuestionStep> questionSteps;
    private boolean finished;
    private Results results;

    public UserSession() {
        finished = false;
        questionSteps = new ArrayList<>();
        //results = new Results();
    }

    public boolean isFinished() {
        return finished;
    }

    public void finishSession() {
        finished = true;
    }

    public void addQuestionStep(QuestionStep questionStep) {
        questionSteps.add(questionStep);
    }

    public QuestionStep getQuestionStep(int index) {
        return questionSteps.get(index);
    }

    public void deleteQuestionStep(QuestionStep questionStep) {
        questionSteps.remove(questionStep);
    }

    public boolean contains(QuestionStep questionStep) {
        return  questionSteps.contains(questionStep);
    }

    public int size() {
        return questionSteps.size();
    }

    public void getResults(){
        results = new Results();
        for(QuestionStep questionStep : questionSteps) {
            if(questionStep.isCorrect())
                results.increaseResults(questionStep.getTheme());
        }
    }

    public void printResults(){
        getResults();
        results.printResults();
    }

    public String getWorseUsersKnownTheme(){
         getResults();
         return results.getWorseUsersKnownTheme();
    }
}
